package com.examlpe.lotterysystem.service.mq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

import static com.examlpe.lotterysystem.common.config.DirectRabbitConfig.*;


@Component
@Slf4j
@RabbitListener(queues = DLX_QUEUE_NAME)
public class DlxReceiver {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RabbitHandler
    public void process(Map<String,String> message) {
        //死信队列消费者处理
        log.info("开始处理异常消息");
        rabbitTemplate.convertAndSend(EXCHANGE_NAME,ROUTING,message);
        //1.接收异常消息课存放数据库表中
        //2.存放后，当前异常消费完成，私信队列消息处理完成，异常消息被持久化存储到表中
        //3.解决异常
        //4.完成脚本任务
        //5.将消息发送给普通队列进行处理
    }

}
